Skip to content

Partial fix for #15048 Inconsistent error severity for invalidFunctionArg - #8962

Merged
chrchr-github merged 2 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_15048_ifa
Oct 31, 2026
Merged

chrchr-github merged 2 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_15048_ifa

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

No description provided.

@dmcppcheck

Copy link
Copy Markdown
Contributor

Test results for commit a718c2e (tools/test-my-pr.py, main compared to this PR):

Test: http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-8962/
packages: 100
Differing warnings: 0 (+0 -0)
Timing: +2.3% (http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-8962/2026-10-26_08-46-54-a718c2ebe421_timing.html)

Posted automatically by the cppcheck PR test runner. +N: warnings only with this PR, -N: warnings only with main. The AI review is written by Claude and can be wrong.

@dmcppcheck dmcppcheck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review

I found no new problems. With this change, invalidFunctionArg drops to warning when the value is conditional, the same as zerodiv/zerodivcond, negativeIndex, negativeMemoryAllocationSize and the STL out-of-bounds check. Values that are known and unconditional still give error.

The downgrade also applies when the invalid value reaches the call on every path, and the "condition" is only an early return before it. For example, int n = -1; if (b) return; memset(buf, 0, n); is now a warning. The other checks above already behave this way (int n = 0; if (b) return 0; return 1 / n; gives zerodivcond warning), so this is consistent and not a regression.

Testing

  • Built cppcheck and testrunner in pr/, and cppcheck in base/.
  • ./testrunner TestFunctions: 61 tests, 0 failed, 7 todos.
  • Compared base and PR on scratch cases with cppcheck -q --enable=warning --template='{line}:{severity}:{id}:{message}':
    • double d=-1.0; if (b) return d; return std::log(d); (the PR's test case): base error, PR warning.
    • double d=-1.0; return std::log(d);: error in both, so unconditional known values are unchanged.
    • if (x == -1) {} return std::sqrt(x);: warning in both.
    • int n=-1; if (b) return; memset(buf,0,n);: base error, PR warning.
    • int c=300; if (b) c=1; return isalpha(c);: warning in both.
  • For consistency I ran the PR binary on int n=0; if (b) return 0; return 1/n;, which gives zerodivcond warning, and on int n=-1; if (b) return; buf[n]=0;, which gives negativeIndex warning. The new invalidFunctionArg severity matches both.
  • No crashes or other differences seen.

Automated review of a718c2e by Claude. The pull request was built and tested locally.

@chrchr-github
chrchr-github merged commit bc89c29 into cppcheck-opensource:main Oct 31, 2026
71 checks passed
@chrchr-github
chrchr-github deleted the chr_15048_ifa branch October 31, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants